let rec power x n = match n with
  |0->1
  |n when n<0 ->invalid_arg "negatif"
  |_->x*(power (x)( n-1)) ;;
let rec application x y=
match x with
  |[]->0
  |(e1,e2)::l->e1*(power y e2)+(application l y);;
let rec add l1 l2 =match (l1,l2) with
  |([],[])->[] 
  |([],l2)->l2
  |(l1,[])->l1
  |(a1,b1)::l1,(c1,e1)::l2 when b1=e1->(a1+c1,b1)::(add l1 l2)
  |(a1,b1)::l1,(c1,e1)::l2 when b1>e1-> (a1,b1)::(c1,e1)::(add l1 l2);;
let rec soustract l1 l2 =match (l1,l2) with
  |([],[])->[] 
  |([],l2)->l2
  |(l1,[])->l1
  |(a1,b1)::l1,(c1,e1)::l2 when b1=e1->(a1-c1,b1)::(add l1 l2)
  |(a1,b1)::l1,(c1,e1)::l2 when b1>e1-> (a1,b1)::(c1,e1)::(add l1 l2);;
let rec  deriv l1=
match l1 with
l[]->[]
  |(a1,b2)::l1-> ((a1*b2),(b2-1))::(deriv l1);;

power 5 2;;
application [(2,2);(2,3);(4,4)] 2;;
add [(1,2);(2,6);(7,8);(2,12)] [(1,4);(3,6);(1,9)];;
soustract [(1,2);(2,6);(7,8);(2,12)] [(1,4);(3,6);(1,9)];;
deriv [(2,2);(2,3);(4,4)];;
